/******************************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
*
* Remarks:
*   This is the head file for RS232 USB device (ACM)
*   (Noted by C.Gu on 07/10/2011)
*
* References:
*
* [1] Universal Serial Bus Class Definition for Communication Devices, Rev 1.2
*     Nov 3, 2010
*
* [2] Universal Serial Bus Communication Class Subclass Specification for 
*     PSTN Devices, Rev 1.2, Feb 9, 2007
******************************************************************************/
#ifndef RS232_LOOP_USB_CONFIG_H
#define RS232_LOOP_USB_CONFIG_H

#include "usb_common.h"
#include "USB_CDC.h"


//===========================================================================
// USB High Speed Interface Descriptor
//===========================================================================

typedef struct {
    USB_STANDARD_INTERFACE_DESCRIPTOR stdInterface;
    USB_STANDARD_ENDPOINT_DESCRIPTOR EP2;
    USB_STANDARD_ENDPOINT_DESCRIPTOR EP4;
    USB_STANDARD_ENDPOINT_DESCRIPTOR EP6;
    USB_STANDARD_ENDPOINT_DESCRIPTOR EP8;
} PACKED USB_HIGH_SPEED_INTERFACE_DESCRIPTOR, PACKED *PUSB_HIGH_SPEED_INTERFACE_DESCRIPTOR;

C_ASSERT(sizeof(USB_HIGH_SPEED_INTERFACE_DESCRIPTOR) == \
    (sizeof(USB_STANDARD_INTERFACE_DESCRIPTOR) + sizeof(USB_STANDARD_ENDPOINT_DESCRIPTOR) * 4));
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//===========================================================================
// USB Full Speed Interface Descriptor
//===========================================================================

typedef USB_HIGH_SPEED_INTERFACE_DESCRIPTOR USB_FULL_SPEED_INTERFACE_DESCRIPTOR;

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


//===========================================================================
// USB CDC ACM High Speed Interface Descriptor
//===========================================================================

typedef struct {
    USB_STANDARD_INTERFACE_DESCRIPTOR                   dataInterface;
    USB_STANDARD_ENDPOINT_DESCRIPTOR                    EP4;
    USB_STANDARD_ENDPOINT_DESCRIPTOR                    EP8;

    CDC_HEADER_FUNCTIONAL_DESCRIPTOR                    headerFunctionalDescriptor;
    CDC_CALL_MANAGEMENT_FUNCTIONAL_DESCRIPTOR           callManagementFunctionalDescriptor;
    ABSTRACT_CONTROL_MANAGEMENT_FUNCTIONAL_DESCRIPTOR   acmFunctionalDescriptor;
    CDC_UNION_FUNCTIONAL_DESCRIPTOR                     unionFunctionalDescriptor;

    USB_STANDARD_INTERFACE_DESCRIPTOR                   notificationInterface;
    USB_STANDARD_ENDPOINT_DESCRIPTOR                    EP6;    // Endpoint for notification

} PACKED USB_CDC_ACM_HIGH_SPEED_INTERFACE_DESCRIPTOR, 
  PACKED *PUSB_CDC_ACM_HIGH_SPEED_INTERFACE_DESCRIPTOR;

C_ASSERT(sizeof(USB_CDC_ACM_HIGH_SPEED_INTERFACE_DESCRIPTOR) == \
        (sizeof(USB_STANDARD_INTERFACE_DESCRIPTOR) * 2 + \
         sizeof(USB_STANDARD_ENDPOINT_DESCRIPTOR) * 3 + \ 
         sizeof(CDC_HEADER_FUNCTIONAL_DESCRIPTOR) + \
         sizeof(CDC_CALL_MANAGEMENT_FUNCTIONAL_DESCRIPTOR) + \
         sizeof(ABSTRACT_CONTROL_MANAGEMENT_FUNCTIONAL_DESCRIPTOR) + \
         sizeof(CDC_UNION_FUNCTIONAL_DESCRIPTOR)));

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    
//===========================================================================
// USB CDC ACM Full Speed Interface Descriptor
//===========================================================================

typedef USB_CDC_ACM_HIGH_SPEED_INTERFACE_DESCRIPTOR USB_CDC_ACM_FULL_SPEED_INTERFACE_DESCRIPTOR;

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



//===========================================================================
// USB High Speed Configuration Descriptor
//===========================================================================

typedef struct {
    USB_STANDARD_CONFIGURATION_DESCRIPTOR stdConfig;
    USB_HIGH_SPEED_INTERFACE_DESCRIPTOR highSpeedInterface;
}PACKED USB_HIGH_SPEED_CONFIG_DESCRIPTOR, PACKED *PUSB_HIGH_SPEED_CONFIG_DESCRIPTOR;

C_ASSERT(sizeof(USB_HIGH_SPEED_CONFIG_DESCRIPTOR) == \
    sizeof(USB_STANDARD_CONFIGURATION_DESCRIPTOR) + sizeof(USB_HIGH_SPEED_INTERFACE_DESCRIPTOR));


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


//===========================================================================
// USB Full Speed Configuration Descriptor
//===========================================================================

typedef struct {
    USB_STANDARD_CONFIGURATION_DESCRIPTOR stdConfig;
    USB_FULL_SPEED_INTERFACE_DESCRIPTOR fullSpeedInterface;
}PACKED USB_FULL_SPEED_CONFIG_DESCRIPTOR, PACKED *PUSB_FULL_SPEED_CONFIG_DESCRIPTOR;

C_ASSERT(sizeof(USB_FULL_SPEED_CONFIG_DESCRIPTOR) == \
    sizeof(USB_STANDARD_CONFIGURATION_DESCRIPTOR) + sizeof(USB_FULL_SPEED_INTERFACE_DESCRIPTOR));

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


//===========================================================================
// USB CDC ACM High Speed Configuration Descriptor
//===========================================================================

typedef struct {
    USB_STANDARD_CONFIGURATION_DESCRIPTOR stdConfig;
    USB_CDC_ACM_HIGH_SPEED_INTERFACE_DESCRIPTOR highSpeedInterface;
}PACKED USB_CDC_ACM_HIGH_SPEED_CONFIG_DESCRIPTOR, PACKED *PUSB_CDC_ACM_HIGH_SPEED_CONFIG_DESCRIPTOR;

C_ASSERT(sizeof(USB_CDC_ACM_HIGH_SPEED_CONFIG_DESCRIPTOR) == \
    sizeof(USB_STANDARD_CONFIGURATION_DESCRIPTOR) + sizeof(USB_CDC_ACM_HIGH_SPEED_INTERFACE_DESCRIPTOR));

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


//===========================================================================
// USB CDC ACM Full Speed Configuration Descriptor
//===========================================================================

typedef struct {
    USB_STANDARD_CONFIGURATION_DESCRIPTOR stdConfig;
    USB_CDC_ACM_FULL_SPEED_INTERFACE_DESCRIPTOR fullSpeedInterface;
}PACKED USB_CDC_ACM_FULL_SPEED_CONFIG_DESCRIPTOR, PACKED *PUSB_CDC_ACM_FULL_SPEED_CONFIG_DESCRIPTOR;

C_ASSERT(sizeof(USB_CDC_ACM_FULL_SPEED_CONFIG_DESCRIPTOR) == \
    sizeof(USB_STANDARD_CONFIGURATION_DESCRIPTOR) + sizeof(USB_CDC_ACM_FULL_SPEED_INTERFACE_DESCRIPTOR));

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//===========================================================================
// USB customized String Descriptor
//===========================================================================
typedef struct {
    USB_STRING_DESCRIPTOR_ZERO descritptorZero;
    USB_UNICODE_STRING_DESCRIPTOR_HEAD manufacturer;
    U16 manufacturerName[8];
    USB_UNICODE_STRING_DESCRIPTOR_HEAD product;
    U16 productName[14];
}PACKED USB_STRING_DESCRIPTOR, PACKED *PUSB_STRING_DESCRIPTOR;

C_ASSERT(sizeof(USB_STRING_DESCRIPTOR) == 52);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#endif

